WTL Controls
Back to the WTL Controls Home Page.
BIS_WTL_CONTROLS::CStaticPlus Class Reference

A very simple CStatic enhancement, providing custom text and background colors. More...

#include <StaticPlus.h>

Inheritance diagram for BIS_WTL_CONTROLS::CStaticPlus:

Public Member Functions

 CStaticPlus () noexcept
 
virtual ~CStaticPlus ()
 
void SubclassStatic (HWND hWnd)
 Subclass a Static TExt control window and create GDI resources. More...
 
void UnSubclassStatic ()
 Un-subclass the window and release GDI resources. More...
 
void SetBtnFaceBkgnd (bool value)
 
bool GetBtnFaceBkgnd () const
 Default: false. More...
 
void SetBackColor (COLORREF value)
 
COLORREF GetBackColor () const
 Default: COLOR_BTNFACE. More...
 
void SetTextColor (COLORREF value)
 
COLORREF GetTextColor () const
 Default: COLOR_WINDOWTEXT. More...
 
void UpdateContent ()
 Wraps Invalidate and UpdateWindow, forcing an immediate redraw. More...
 

Detailed Description

A very simple CStatic enhancement, providing custom text and background colors.

This class provides custom background and text colors by handling the reflected WM_CTLCOLORSTATIC. A bool BtnFaceBkgnd will override the background color to force the background to the system-defined value, but it is false by default.

This control isn't double-buffered, but an UpdateContent member function is included anyway; it calls Invalidate and UpdateWindow in sequence.

The member function SubclassStatic modifies the sub-classed window's style to include the SS_NOTIFY flag. The parent dialog must reflect WM_CTLCOLORSTATIC back to the control, with either the non-discriminating REFLECT_NOTIFICATIONS, or with something more selective (e.g, REFLECT_NOTIFICATIONS_MSG_FILTERED).

Sample usage is depicted below.

Stat1.SubclassStatic(GetDlgItem(IDC_STAT1));
Stat1.SetBackColor(COLOR_RED);
Stat1.SetTextColor(COLOR_WHITE);
.
.
.
Stat1.UnSubclassStatic(); // when finished using the control (probably in OnEndDialog).

Definition at line 52 of file StaticPlus.h.

Constructor & Destructor Documentation

◆ CStaticPlus()

BIS_WTL_CONTROLS::CStaticPlus::CStaticPlus ( )
noexcept

Definition at line 21 of file StaticPlus.cpp.

◆ ~CStaticPlus()

BIS_WTL_CONTROLS::CStaticPlus::~CStaticPlus ( )
virtual

Definition at line 33 of file StaticPlus.cpp.

Member Function Documentation

◆ SubclassStatic()

void BIS_WTL_CONTROLS::CStaticPlus::SubclassStatic ( HWND  hWnd)

Subclass a Static TExt control window and create GDI resources.

The SS_NOTIFY flag is added to the control's window styles, as well.

Parameters
hWndThe handle of the static text control window to be subclassed.
Return values
void

Definition at line 52 of file StaticPlus.cpp.

◆ UnSubclassStatic()

void BIS_WTL_CONTROLS::CStaticPlus::UnSubclassStatic ( )

Un-subclass the window and release GDI resources.

Return values
void

Definition at line 69 of file StaticPlus.cpp.

◆ SetBtnFaceBkgnd()

void BIS_WTL_CONTROLS::CStaticPlus::SetBtnFaceBkgnd ( bool  value)

Definition at line 123 of file StaticPlus.cpp.

◆ GetBtnFaceBkgnd()

bool BIS_WTL_CONTROLS::CStaticPlus::GetBtnFaceBkgnd ( ) const

Default: false.

Definition at line 118 of file StaticPlus.cpp.

◆ SetBackColor()

void BIS_WTL_CONTROLS::CStaticPlus::SetBackColor ( COLORREF  value)

Definition at line 86 of file StaticPlus.cpp.

◆ GetBackColor()

COLORREF BIS_WTL_CONTROLS::CStaticPlus::GetBackColor ( ) const

Default: COLOR_BTNFACE.

Definition at line 81 of file StaticPlus.cpp.

◆ SetTextColor()

void BIS_WTL_CONTROLS::CStaticPlus::SetTextColor ( COLORREF  value)

Definition at line 107 of file StaticPlus.cpp.

◆ GetTextColor()

COLORREF BIS_WTL_CONTROLS::CStaticPlus::GetTextColor ( ) const

Default: COLOR_WINDOWTEXT.

Definition at line 102 of file StaticPlus.cpp.

◆ UpdateContent()

void BIS_WTL_CONTROLS::CStaticPlus::UpdateContent ( )

Wraps Invalidate and UpdateWindow, forcing an immediate redraw.

Definition at line 138 of file StaticPlus.cpp.


The documentation for this class was generated from the following files: